package gateway.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GateWayConfig
{
    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder)
    {
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        // 当前路由所有的地址都转发到http://127.0.0.1:9302/c3
        routes.route("path_route_atguigu",
                r -> r.path("/c3")
                        .uri("http://127.0.0.1:9302/c3")).build();

        return routes.build();
    }
}
